﻿@{
    Layout = null;
}
@model System.Domain.Entities.Menu;
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width" />
    <link href="~/css/fbw.css" rel="stylesheet" />
    <style>
        .hn-input-icon {
            position: relative;
        }

            .hn-input-icon i {
                position: absolute;
                right: 12px;
                cursor: pointer;
                top: 30%;
            }

        .layui-form-item .layui-input-inline {
            width: 350px;
        }
    </style>
</head>
<body>
    <div id="" class="layui-layer-content" style="height: 100%; width: 87%; margin: 0 auto;">
        <form class="layui-form" id="hn-form" lay-filter="hn-form" action="" style="margin-top: 50px;">
            <input type="hidden" name="id" value="@(Model.id)" />
            <input type="hidden" name="parentId" value="@(Model.parentId)" />
            <input type="hidden" name="typeId" value="1" />
            <div class="layui-form-item">
                <label class="layui-form-label required">菜单名称</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="name" lay-verify="required" name="name" type="text" value="@(Model.name??"")">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Url</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="url" name="url" type="text" value="@(Model.url??"")">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">图标</label>
                <div class="layui-input-inline">
                    <div class="hn-input-icon">
                        <input class="layui-input" id="icon" name="icon" type="text" value="@(Model.icon??"")">
                        <i class="layui-icon layui-icon-search"></i>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <input type='checkbox' name='isDel' id="isDel" value='0' lay-skin='switch' lay-text='启用|禁用' lay-filter='is_del' @((Model.isDel == 0) ? "checked" : "")>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">介绍</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="content" lay-verify="" name="content" type="text" value="@(Model.content??"")">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">显示顺序</label>
                <div class="layui-input-inline">
                    <input value="@(Model.px)" class="layui-input" data-val="true" data-val-number="字段 px 必须是一个数字。" data-val-required="px 字段是必需的。" id="px" lay-verify="required|number_z" name="px" type="text">
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit="" lay-filter="btn-submit-updatePopedom" id="btn-submit-updatePopedom" value="确认">
            </div>
        </form>
        <script src="~/lib/jquery/dist/jquery.js"></script>
        <script type="text/javascript">
            var laydom;
            function OpenIcon() {
                var wd = ['600px', '550px'];
                var winheight = $(window).height();
                if (winheight < 600) {
                    wd = ['100%', '100%'];
                }
                laydom = layer.open({
                    type: 2,
                    title: '选择图标',
                    area: wd,
                    content: '/Menu/Icon',
                    success: function (layero, index) {

                    }
                });
            }
            layui.config({
                base: '/layuiadmin/'
            })
            layui.use(['form'], function () {
                var form = layui.form;
                var $ = layui.$;
                form.on("submit(btn-submit-updatePopedom)", function (data) {
                    if ($("#isDel").get(0).checked) {
                        data.field.isDel = 0;
                    } else {
                        data.field.isDel = 1;
                    }
                    $.post("/Menu/Add", data.field, function (ret) {
                        if (ret.status == 1) {
                            layer.msg(ret.message, {
                                icon: 1,
                                time: 1000 //1秒关闭
                            }, function () {
                                layui.treeGrid.reload('tb');
                                layer.closeAll();
                            });
                        } else {
                            layer.msg(ret.message);
                        }
                    });
                    return false;
                })
                form.render();
            })

            $("#hn-form .layui-icon-search").click(OpenIcon)

            function GetIcon(className) {
                layer.close(laydom);
                $("#icon").val(className);
            }
        </script>
    </div>
</body>
</html>
